package shark.permission.service;

import com.baomidou.mybatisplus.extension.service.IService;
import shark.permission.model.SysPermissionTree;
import shark.permission.spi.entity.SysPermission;

import java.util.List;
import java.util.Map;

public interface ISysPermissionService extends IService<SysPermission> {
    List<SysPermissionTree> queryListByParentId(String parentId);

    void deletePermission(String id);

    void deletePermissionLogical(String id);

    void addPermission(SysPermission sysPermission);

    void editPermission(SysPermission sysPermission);

    Map<String, List<SysPermission>> getAuthorize();

    List<SysPermission> queryByUser(String username);

    List<SysPermissionTree> queryTreeByUser(String username);

    /**
     * 判断用户否拥有权限
     * @param username
     * @param sysPermission
     * @return
     */
    boolean hasPermission(String username, SysPermission sysPermission);

    /**
     * 根据用户和请求地址判断是否有此权限
     * @param username
     * @param url
     * @return
     */
    boolean hasPermission(String username, String url);
}
